var status = 0;
var team = 0;

function start() {
    status = -1;
    action(1, 0, 0);
}
 
function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
		cm.getRedMembers();
	} else if (status == 1) {
		cm.getBlueMembers();
	} else if (status == 2) {
		cm.sendSimple("So, what team do you want?\r\n#r#L1#I want to be in team Red#k#l\r\n#L2##bI want to be in team Blue#k#l");
	} else if (status == 3) {
		team = selection;
		cm.sendYesNo("Are you sure?");
	} else {
		if (team == 1) {
			cm.setRed();
			cm.sendOk("You are now in team red, relog to see the effect");
			cm.dispose();
		} else {
			cm.setBlue();
			cm.sendOk("You are now in team blue, relog to see the effect");
			cm.dispose();
		}
	}
    }
}